Top 10k strings from M-Code Library 4 - Screen Swapping (1985)(16-48 Tape Magazine).z80
in <root> / bin / z80 / software / Sinclair Spectrum Collection TOSEC.exe / Sinclair ZX Spectrum - Utilities & Educational / Sinclair ZX Spectrum - Utilities & Educational - [Z80] (TOSEC-v2007-01-01) /
Back to the directory listing
3 ;"lib4code" 3 )*(l>lc),16 2 SCREEN SWAPPING ROUTINES 2 ;"swapcode" 2 ;"library 4" 2 "swapcode" 2 "lib4code" 1 z$="10020203 1 z$="04030104 1 z$="01020104 1 store screen. 1 l=l+(l<max)*(k$="6" 1 assembly listings 1 VERTICAL ROUTINE 1 SWAPPING SCREENS 1 STOP THE TAPE 1 SAVE""swapcode""CODE 60000,88 1 RUN THE TAPE 1 PRESS A KEY 1 M/CODE LIBRARY 4 1 LET THE TAPE RUN 1 HORIZONTAL SWAP 1 GENERAL NOTES 1 ASSEMBLY LISTING 1 ;"library 4": 1 ;"Verified O.K. Press any key. ": 1 ;"Use up and down keys to read thenotes. 1 ;"This month have two routines forexchanging the current screen display with a screen stored in RAM." 1 ;"The first routine resides at 60000 and is 64 bytes long."'"You need to poke 60004 and 60005with the low and high bytes of the address of the screen you have stored." 1 ;"Saved and verified O.K. 1 ;"Rewind and play to verify.": 1 60000 will then swap the current screen for the one in memory and a repeated call will swap back again." 1 *(l>lc);a$: 1 '"Unlike simply using LDIR to calldown a screen from RAM these routines do not lose the currentscreen." 1 '"The second routine swaps one byte at a time and, while not sopretty, is much faster." 1 '"The horizontal swap is 24 bytes long and starts at 60064. You need to poke 60065 and 60066 with the picture address and RANDOMIZE 1 '"The first one works a bit like a vertical venetian blind. The pictures are exchanged by 1 '"RANDOMIZE 1 '"Both routines can be relocated at any address." 1 "library 4" 1 "23658",o: 1 ","Rotate the next pair of bytes ifnot finished." 1 ","Repeat if not finished."," RET","Back to basic if finished." 1 ","Repeat if not finished." 1 ","Repeat if not finised." 1 "(300+100* 1 " RET","Back to BASIC." 1 " POP HL","Get the store address back."," POP DE","Get the display address back."," POP BC","Reset the byte counter."," POP AF","Get the rotation counter back."," DEC A","One less rotation to do."," JR NZ, 1 " LD HL,STORE","Put the stored screen address inHL."," LD DE,4000H","Display file address goes in DE."," LD BC,1B00h","Whole screen length into BC as acounter." 1 " LD DE,4000h","Screen address in DE."," LD HL,STORE","Put stored screen address in HL."," LD BC,1800H","BC holds the number of bytes in one screen." 1 " LD BC,1800h","This is the gap between the 1 " LD A,B","High byte in A..."," OR C","Or with Low byte to test for 0."," JR NZ, 1 " LD A,8","We need 8 rotations. A is the counter."," 1 " LD (HL),B","One byte done.."," LD (DE),A"," ...and the other. No need to swap HL and DE back as the orderdoes not matter." 1 " INC HL","Move on to the next byte."," INC DE","Move on the other pointer."," POP BC","Retreive the counter." 1 " INC HL","Move on to next stored byte."," INC DE","Move on to next displayed byte."," POP BC","Fetch the byte counter."," DEC BC","One less to do." 1 " EX DE,HL","Now back to the stored byte."," RL (HL)","Rotate the screen bit from the carry into bit 0."," INC DE","Move on to the next screen byte."," INC HL","Move on to the next stored byte." 1 " DEC BC","One less to do."," LD A,B","Usual test for zero..."," OR C","Gives zero if BC=0."," JR NZ, 1 " DEC BC","One less to do."," LD A,B","Put high byte of counter in A..."," OR C","and if BC=0 then this will set the zero flag."," JR NZ, 1 to move on, 1 to copy." 1 rotating vertical strips one pixel at a time." 1 down for a demo. " 1 display file and the attribute file."," ADD HL,BC","HL now points to the stored 1 attributes."," LD DE,5800h","DE points to the attribute file."," LD BC,0030h","BC counts the attribute bytes." 1 RLC (HL)","Put bit seven of a stored byte in the carry flag."," RRC (HL)","Restore the byte."," EX DE,HL","Now work on the screen byte."," RL (HL)","Bit 7 goes in the carry flag andbit 0 collects the stored bit." 1 Press any key.": 1 PUSH BC","Save the counter."," LD B,(HL)","Fetch the stored byte."," LD A,(DE)","Fetch the displayed byte."," EX DE,HL","Prepare to swap." 1 PUSH BC","Save the counter."," LD B,(HL)","Fetch stored byte."," LD A,(DE)","Fetch displayed byte."," EX DE,HL","Prepare for swap."," LD (DE),A","Stored byte goes to the screen."," LD (HL),B","Displayed byte goes to store." 1 PUSH AF","Save the rotation counter."," PUSH BC","Save the byte counter."," PUSH DE","Save the display address."," PUSH HL","Save the store address." 1 ATTRIBUTE SWAP 1 for tape,"; 1 for microdrive,"; 1 for menu." 1 HOW TO USE IT